%Declare the symbolic variables (syms)
syms lg1Val lg0Val sVal phiVal lb0Val u0Val deltaVal
f=lg1Val-(lg0Val+sVal*phiVal*(1-xib)*lb0Val+phiVal*(1-xib)*u0Val ); %Leonardo modified it 20/01/2021
%Take symbolic derivatives
dd1 = diff(f,lg1Val);
dd2 = diff(f,lg0Val);
dd3 = diff(f,sVal);
dd4 = diff(f,phiVal);
dd5 = diff(f,lb0Val);
dd6 = diff(f,u0Val);
%dd7 = diff(f,deltaVal); %Leonardo modified it 20/01/2021
%dd8 = diff(f,xibVal);

%Evaluates symbolic derivatives
lg1Val=lg;   %linearization
lg0Val=lg;   %linearization
sVal=s;  %linearization
phiVal=phi0;   %linearization %Renato modified 21/12
lb0Val=lb; %linearization
u0Val=U0star; %linearization
%deltaVal=delta; %linearization %Leonardo modified it 20/01/2021
%xibVal=xib; %linearization

%Substitute the symbolic values into the equations for the partial derivatives
D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
D5=subs(dd5);
D6=subs(dd6);
%D7=subs(dd7); %Leonardo modified it 20/01/2021
%D8=subs(dd8);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
d5=double(D5);
d6=double(D6);
% d7=double(D7); %Leonardo modified it 20/01/2021
%d8=double(D8);

ACont(6,lgLog)     = d1;
% ALag(6,lgLog)      = -d2;
ACont(6,lg0Log)      = d2; %Leonardo modified it 20/01/2021
ACont(6,shksLog)    = d3;
ACont(6,phiLog)    = d4;
% ALag(6,lb0Log)       = -d5;
ACont(6,lbLog)       = d5; %Leonardo modified it 20/01/2021
ACont(6,uzeroLog)  = d6; 
% ACont(6,shkdeltaLog)=d7; %Leonardo modified it 20/01/2021
%ACont(6,shkxibLog)=d8;

